#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

const char *filename = "log.txt";

int main()
{
    //close(1);
    int fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
    if(fd < 0)
    {
        perror("open");
        return 1;
    }
    
    printf("printf, fd: %d\n", fd);
    fprintf(stdout, "fprintf, fd: %d\n", fd);
    
    fflush(stdout);
    
    
    close(fd);
    
    return 0;
}
